package constructor;

public class Demo2 {
    public static void main(String[] args) {
        Student s = new Student();
        s.setName("wzx");
        s.setAge(18);
        System.out.println(s.getName()+"..."+s.getAge());
        //getXxx()获取属性值，可以打印，也可以赋值给其他变量，做其他操作
        Student s1 = new Student("sad",20);
        s1.show();
    }
}
class Student {
    private String name;
    private int age;

    public Student() { }//空参构造
    public Student(String name,int age) {//有参构造
        this.name = name;
        this.age = age;
    }

    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public int getAge() {
        return age;
    }
    public void show() {
        System.out.println("我的姓名是："+ name +",我的年龄是："+age);
    }









}
